package com.diy.common.aop;

import com.diy.common.baseModel.DiyResponse;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;

/**
 * Created by GY on 2015/11/22.
 */

//@Aspect
@Component
public class MapperNameHandlerAspect implements Ordered {


    private static final String EDP = "execution(* com.diy.common.bussiness.controller.create(..)) || execution(* com.diy.common.bussiness.controller.edit(..))|| execution(* com.diy.common.bussiness.controller.single(..)|| execution(* com.diy.common.bussiness.controller.query(..)|| execution(* com.diy.common.bussiness.controller.delete(..))";
    @Pointcut(EDP)
    private void aspect() {}


    @Before(value = EDP)
    public void before(JoinPoint joinPoint, DiyResponse diyResponse){
System.out.println("Before");
    }


    @After(value = EDP)
    public void after(JoinPoint joinPoint, DiyResponse diyResponse){
        System.out.println("After");
    }

    @AfterReturning(pointcut = "aspect()",returning = "diyResponse")
    public void afterReturn(JoinPoint joinPoint, DiyResponse diyResponse){
        System.out.println("AfterReturning");
    }

    @AfterThrowing(pointcut = "aspect()",throwing = "ex")
    public void afterThrow(JoinPoint joinPoint, RuntimeException ex){
        System.out.println("AfterThrowing");
    }

    @Override
    public int getOrder() {
        return 5;
    }
}
